//
//  AXMyInSaleTableViewCell.m
//  AnXin100
//
//  Created by 天质弘耕 on 2018/10/16.
//  Copyright © 2018年 tzhg. All rights reserved.
//

#import "AXMyInSaleTableViewCell.h"
#import "UIView+SDAutoLayout.h"
#import "ZXCategories.h"
#import "UITableView+SDAutoTableViewCellHeight.h"

@implementation AXMyInSaleTableViewCell

- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier {
    
    if (self = [super initWithStyle:style reuseIdentifier:reuseIdentifier]) {
        
        [self creatView];
        [self setlayout];
    }
    return self;
}

- (void)creatView {
    /** 服务单号 */
    self.serveNumberLabel = [[UILabel alloc]init];
    self.serveNumberLabel.text = @"服务单号:HD12334445555544";
    self.serveNumberLabel.textAlignment = NSTextAlignmentLeft;
    self.serveNumberLabel.font = FONT_FOURTEEN;;
    self.serveNumberLabel.textColor = COLOR_Gray;
    [self.contentView addSubview:self.serveNumberLabel];
    /** 退货退款 */
    self.backGoods = [[UIButton alloc]init];
    self.backGoods.titleLabel.font = FONT_FOURTEEN;;
    [self.backGoods setTitle:@"退货退款" forState:UIControlStateNormal];
    [self.backGoods setTitleColor:COLOR_Gray forState:UIControlStateNormal];
    [self.contentView addSubview:self.backGoods];
    /** 产品图片 */
    self.productImageView = [[UIImageView alloc]init];
    self.productImageView.contentMode =UIViewContentModeScaleAspectFill;
    self.productImageView.clipsToBounds=YES;//
    [self.contentView addSubview:self.productImageView];
    /** 产品名字 */
    self.productNameLabel = [[UILabel alloc]init];
    self.productNameLabel.font = FONT_FOURTEEN;;
    self.productNameLabel.numberOfLines = 2;
    self.productNameLabel.textColor = [UIColor colorWithHex:0x666666];
    [self.contentView addSubview:self.productNameLabel];
    /** 产品合计 */
    self.productCountLabel = [[UILabel alloc]init];
    self.productCountLabel.textColor = [UIColor colorWithHex:0x666666];
    self.productCountLabel.font = FONT_TWELVE;
    self.productCountLabel.text = @"共一件商品 合计 98（含运费10元）";
    [self.contentView addSubview:self.productCountLabel];
    /** 待您反馈 */
    self.ticklingLabel = [[UILabel alloc]init];
    self.ticklingLabel.text = @"待您反馈";
    self.ticklingLabel.textColor = COLOR_Gray;
    self.ticklingLabel.font = FONT_FOURTEEN;;
    [self.contentView addSubview:self.ticklingLabel];
    /** 服务受理中*/
    self.serveTimeLabel = [[UILabel alloc]init];
    self.serveTimeLabel.numberOfLines = 3;
    [self.contentView addSubview:self.serveTimeLabel];
    /** 取消申请*/
    self.cancelButton = [[UIButton alloc]init];
    self.cancelButton.titleLabel.font = FONT_FOURTEEN;;
    self.cancelButton.backgroundColor = COLOR_ORG;
    [self.cancelButton setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
    [self.cancelButton setTitle:@"申请取消" forState:UIControlStateNormal];
    [self.contentView addSubview:self.cancelButton];
    
    if (SCREEN_WIDTH <= 320) {
        self.productNameLabel.font = FONT_TWELVE;
        self.productCountLabel.font = FONT_TWELVE;
        self.ticklingLabel.font = FONT_TWELVE;
        self.serveTimeLabel.font = [UIFont systemFontOfSize:10];
        self.cancelButton.titleLabel.font = FONT_TWELVE;
    }
    
    
}

- (void)setlayout {
    /** 服务单号 */
    self.serveNumberLabel.sd_layout
    .leftSpaceToView(self.contentView, 10)
    .topSpaceToView(self.contentView, 0)
    .widthIs(SCREEN_WIDTH-100)
    .heightIs(30);
    /** 待付款 */
    self.backGoods.sd_layout
    .rightSpaceToView(self.contentView, 10)
    .topSpaceToView(self.contentView, 0)
    .widthIs(70)
    .heightIs(30);
    /* 产品图片 **/
    self.productImageView.sd_layout
    .leftSpaceToView(self.contentView, 10)
    .topSpaceToView(self.serveNumberLabel, 0)
    .widthIs(100)
    .heightIs(100);
    /** 产品名字 */
    self.productNameLabel.sd_layout
    .leftSpaceToView(self.productImageView, 10)
    .topSpaceToView(self.backGoods, 0)
    .rightSpaceToView(self.contentView, 10)
    .heightIs(40);
    /* 产品合计 **/
    self.productCountLabel.sd_layout
    .leftEqualToView(self.productNameLabel)
    .rightSpaceToView(self.contentView, 10)
    .topSpaceToView(self.productNameLabel, 0)
    .heightIs(30);
    /* 反馈 **/
    self.ticklingLabel.sd_layout
    .leftSpaceToView(self.contentView, 10)
    .topSpaceToView(self.productImageView, 10)
    .widthIs(60)
    .heightIs(30);
    /** 去支付按钮 */
    self.cancelButton.sd_layout
    .rightSpaceToView(self.contentView, 10)
    .topSpaceToView(self.productImageView, 10)
    .widthIs(60)
    .heightIs(30);
    /** 服务受理中 */
    self.serveTimeLabel.sd_layout
    .rightSpaceToView(self.cancelButton, 10)
    .topSpaceToView(self.productImageView, 10)
    .leftSpaceToView(self.ticklingLabel, 10)
    .heightIs(40);
    
    if (SCREEN_WIDTH <= 320 ) {
        /* 价格 **/
        self.ticklingLabel.sd_layout
        .leftSpaceToView(self.productImageView, 10)
        .topSpaceToView(self.productCountLabel, 0)
        .widthIs(40)
        .heightIs(25);
        /** 去支付按钮 */
        self.cancelButton.sd_layout
        .rightSpaceToView(self.contentView, 10)
        .topSpaceToView(self.productCountLabel, 0)
        .widthIs(40)
        .heightIs(25);

    }
    
    /** cell高度自适应第一步 */
    [self setupAutoHeightWithBottomView:self.serveTimeLabel bottomMargin:10];
    
}

@end

